home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / modes / winmgr-mode.el.z / winmgr-mode.el
Encoding:
Text File  |  1998-05-21  |  4.7 KB  |  171 lines

  1. ;;; winmgr-mode.el --- generic window manager mode
  2.  
  3. ;; Author: ???
  4. ;; Maintainer: David Konerding (rafael@cse.ucsc.edu)
  5. ;; Modifications by: Stefan Strobel <strobel@lia.univ-savoie.fr>
  6. ;;                   Barry A. Warsaw <bwarsaw@python.org>
  7. ;; Created: ???
  8. ;; Keywords: languages
  9.  
  10. ;; Copyright (C) 199? Someone Claim It
  11.  
  12. ;; This file is part of XEmacs.
  13.  
  14. ;; XEmacs is free software; you can redistribute it and/or modify it
  15. ;; under the terms of the GNU General Public License as published by
  16. ;; the Free Software Foundation; either version 2 of the License, or
  17. ;; (at your option) any later version.
  18.  
  19. ;; XEmacs is distributed in the hope that it will be useful, but
  20. ;; WITHOUT ANY WARRANTY; without even the implied warranty of
  21. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  22. ;; General Public License for more details.
  23.  
  24. ;; You should have received a copy of the GNU General Public License
  25. ;; along with XEmacs; if not, write to the Free Software
  26. ;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  27. ;; 02111-1307, USA.
  28.  
  29. ;;; Synched up with: Not in FSF.
  30.  
  31. ;;; Commentary:
  32.  
  33. ;; This package is a major mode for editing window configuration files and
  34. ;; also defines font-lock keywords for such files.
  35.  
  36. ;; winmgr-mode mode will automatically get turned on if you visit a
  37. ;; a file whose name looks like that of a configuration file
  38. ;; (IE, .fvwmrc, .mwmrc, .tvtwmrc, etc)
  39.  
  40. ;; The current font-lock keywords are:
  41.  
  42. ;; any word of upper or lower case letters at the start of a line
  43. ;; followed by whitespace gets colored using
  44. ;; font-lock-function-name-face.
  45.  
  46. ;; any word of upper or lower case letters at the start of a line
  47. ;; followed by a "(" (IE, an m4 macro) gets colored using
  48. ;; font-lock-comment-face
  49.  
  50. ;; Put this in your .emacs :
  51. ;;
  52. ;;(setq auto-mode-alist
  53. ;;      (append '(("\\.[A-Za-z]*wm$" . winmgr-mode)
  54. ;;              ("\\.[A-Za-z]*wmrc" . winmgr-mode) 
  55. ;;          auto-mode-alist))
  56. ;;
  57. ;;(autoload 'winmgr-mode "winmgr-mode"
  58. ;;  "Mode for editing window manager config files")
  59. ;;
  60. ;;(add-hook 'winmgr-mode-hook
  61. ;;      '(lambda ()
  62. ;;         (font-lock-mode t)
  63. ;;         (setq font-lock-keywords winmgr-font-lock-keywords)
  64. ;;           (font-lock-fontify-buffer)))
  65. ;;
  66.  
  67.  
  68. ;;; Code:
  69.  
  70. (defgroup winmgr nil
  71.   "Generic window manager mode."
  72.   :tag "Window Managers"
  73.   :group 'languages)
  74.  
  75.  
  76. (defcustom winmgr-basic-offset 4
  77.   "*Number of spaces per indentation level."
  78.   :type 'integer
  79.   :group 'winmgr)
  80.  
  81. (defcustom winmgr-mode-hook nil
  82.   "Hook to be run when `winmgr-mode' is entered."
  83.   :type 'hook
  84.   :group 'winmgr)
  85.  
  86.  
  87. (defface font-lock-m4-face
  88.   '((((class color))
  89.      (:foreground "blue"))
  90.     (t
  91.      (:underline t)))
  92.   "Font-lock face for M4 macros."
  93.   :group 'winmgr)
  94.  
  95. (defvar winmgr-font-lock-keywords 
  96.   '(("^[A-Za-z]+[ \n\t]" . font-lock-function-name-face)
  97.     ;;("^#.*" . font-lock-comment-face)
  98.     ("^[A-Za-z]+(.*)" . font-lock-m4-face))
  99.   "Default font-lock keywords.")
  100.  
  101.  
  102. ;; major-mode stuff
  103. (defvar winmgr-mode-abbrev-table nil
  104.   "Abbrev table used in `winmgr-mode' buffers.")
  105. (define-abbrev-table 'winmgr-mode-abbrev-table ())
  106.  
  107.  
  108. (defvar winmgr-mode-syntax-table nil
  109.   "Syntax table used in `winmgr-mode' buffers.")
  110. (if winmgr-mode-syntax-table
  111.     ()
  112.   (setq winmgr-mode-syntax-table (make-syntax-table))
  113.   (modify-syntax-entry ?\#  "<" winmgr-mode-syntax-table)
  114.   (modify-syntax-entry ?\n ">" winmgr-mode-syntax-table))
  115.  
  116.  
  117. (defvar winmgr-mode-map ()
  118.   "Keymap used in `winmgr-mode' buffers.")
  119. (if winmgr-mode-map
  120.     ()
  121.   (setq winmgr-mode-map (make-sparse-keymap))
  122.   ;; So far there aren't any winmgr-mode specific functions
  123.   )
  124.  
  125.  
  126. ;;;###autoload
  127. (defun winmgr-mode ()
  128.   "Major mode for editing winmgr config files."
  129.   (interactive)
  130.   (kill-all-local-variables)
  131.   (set-syntax-table winmgr-mode-syntax-table)
  132.   (setq major-mode 'winmgr-mode
  133.     mode-name "Winmgr"
  134.     local-abbrev-table winmgr-mode-abbrev-table)
  135.   (use-local-map winmgr-mode-map)
  136.   ;; local variables
  137.   (make-local-variable 'parse-sexp-ignore-comments)
  138.   (make-local-variable 'comment-start)
  139.   (make-local-variable 'comment-end)
  140.   (make-local-variable 'indent-line-function)
  141.   ;; now set their values
  142.   (setq parse-sexp-ignore-comments t
  143.     comment-start "# "
  144.     comment-end ""
  145.     indent-line-function 'winmgr-indent-line-function)
  146.   (run-hooks 'winmgr-mode-hook))
  147.  
  148.  
  149. ;; indentation commands
  150.  
  151. (defun winmgr-indent-line-function ()
  152.   "Indent line based on depth in parentheses.
  153. See the variable `winmgr-basic-offset.'"
  154.   ;; find the beginning of this construct
  155.   (let ((depth 0)
  156.     (here (point)))
  157.     (condition-case nil
  158.     (while t
  159.       (backward-up-list 1)
  160.       (setq depth (1+ depth)))
  161.       (error nil))
  162.     (goto-char here)
  163.     (beginning-of-line)
  164.     (delete-horizontal-space)
  165.     (insert-char ?\040 (* depth winmgr-basic-offset))))
  166.  
  167.  
  168. (provide 'winmgr-mode)
  169.  
  170. ;;; winmgr-mode.el ends here
  171.